﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// SchoolCookie
/// 学校,学生系统的当前处于打开状态的考试COOKIE获取方法
/// </summary>
public class SchoolCookie
{
    /// <summary>
    /// 设置一个打开的考试信息
    /// </summary>
    /// <param name="examType"></param>
    /// <param name="examID"></param>
    /// <param name="grade"></param>
    /// <param name="classType"></param>
    public static bool SetOpenedExam(int examType,int examID,string examname,int grade,int classType,int canupload)
    {
        if (CommonScore.GetSchoolMark!=null)
        {
            System.Web.HttpContext.Current.Session["ExamType_" + CommonScore.GetAreaID + "_" + CommonScore.GetUserCode + "_" + CommonScore.GetSchoolMark]= System.Web.HttpContext.Current.Server.UrlEncode(examType.ToString());

            System.Web.HttpContext.Current.Session["ExamID_" + CommonScore.GetAreaID + "_" + CommonScore.GetUserCode + "_" + CommonScore.GetSchoolMark]= System.Web.HttpContext.Current.Server.UrlEncode(examID.ToString());

            System.Web.HttpContext.Current.Session["ExamName_" + CommonScore.GetAreaID + "_" + CommonScore.GetUserCode + "_" + CommonScore.GetSchoolMark]= System.Web.HttpContext.Current.Server.UrlEncode(examname);

            System.Web.HttpContext.Current.Session["ExamGrade_" + CommonScore.GetAreaID + "_" + CommonScore.GetUserCode + "_" + CommonScore.GetSchoolMark]= System.Web.HttpContext.Current.Server.UrlEncode(grade.ToString());

            System.Web.HttpContext.Current.Session["ExamClassType_" + CommonScore.GetAreaID + "_" + CommonScore.GetUserCode + "_" + CommonScore.GetSchoolMark]= System.Web.HttpContext.Current.Server.UrlEncode(classType.ToString());

            System.Web.HttpContext.Current.Session["CanUploadScore_" + CommonScore.GetAreaID + "_" + CommonScore.GetUserCode + "_" + CommonScore.GetSchoolMark]= System.Web.HttpContext.Current.Server.UrlEncode(canupload.ToString());

        }
        return false;
        
    }
    /// <summary>
    /// 清空考试信息缓存
    /// </summary>
    public static void ClearExamInfo()
    {
        //if (System.Web.HttpContext.Current.Request.Cookies["ExamType_" + CommonScore.GetAreaID + "_" + CommonScore.GetUserCode + "_" + CommonScore.GetSchoolMark] != null)
        //{
        //    System.Web.HttpContext.Current.Response.Cookies.Remove("ExamType_" + CommonScore.GetAreaID + "_" + CommonScore.GetUserCode + "_" + CommonScore.GetSchoolMark);
        //}
        //if (System.Web.HttpContext.Current.Request.Cookies["ExamID_" + CommonScore.GetAreaID + "_" + CommonScore.GetUserCode + "_" + CommonScore.GetSchoolMark] != null)
        //{
        //    System.Web.HttpContext.Current.Response.Cookies.Remove("ExamID_" + CommonScore.GetAreaID + "_" + CommonScore.GetUserCode + "_" + CommonScore.GetSchoolMark);
        //}
        //if (System.Web.HttpContext.Current.Request.Cookies["ExamName_" + CommonScore.GetAreaID + "_" + CommonScore.GetUserCode + "_" + CommonScore.GetSchoolMark] != null)
        //{
        //    System.Web.HttpContext.Current.Response.Cookies.Remove("ExamName_" + CommonScore.GetAreaID + "_" + CommonScore.GetUserCode + "_" + CommonScore.GetSchoolMark);
        //}
        //if (System.Web.HttpContext.Current.Request.Cookies["ExamGrade_" + CommonScore.GetAreaID + "_" + CommonScore.GetUserCode + "_" + CommonScore.GetSchoolMark] != null)
        //{
        //    System.Web.HttpContext.Current.Response.Cookies.Remove("ExamGrade_" + CommonScore.GetAreaID + "_" + CommonScore.GetUserCode + "_" + CommonScore.GetSchoolMark);
        //}

        //if (System.Web.HttpContext.Current.Request.Cookies["ExamClassType_" + CommonScore.GetAreaID + "_" + CommonScore.GetUserCode + "_" + CommonScore.GetSchoolMark] != null)
        //{
        //    System.Web.HttpContext.Current.Response.Cookies.Remove("ExamClassType_" + CommonScore.GetAreaID + "_" + CommonScore.GetUserCode + "_" + CommonScore.GetSchoolMark);
        //}

        //if (System.Web.HttpContext.Current.Request.Cookies["CanUploadScore_" + CommonScore.GetAreaID + "_" + CommonScore.GetUserCode + "_" + CommonScore.GetSchoolMark] != null)
        //{
        //    System.Web.HttpContext.Current.Response.Cookies.Remove("CanUploadScore_" + CommonScore.GetAreaID + "_" + CommonScore.GetUserCode + "_" + CommonScore.GetSchoolMark);
        //}
    }
    /// <summary>
    /// 取得考试类型
    /// </summary>
    public static int ExamType
    {
        get 
        {
            if (CommonScore.GetSchoolMark == "" || System.Web.HttpContext.Current.Session["ExamType_" + CommonScore.GetAreaID + "_" + CommonScore.GetUserCode + "_" + CommonScore.GetSchoolMark] == null)
            {
                return -1;
            }
            string temp = System.Web.HttpContext.Current.Server.UrlDecode(System.Web.HttpContext.Current.Session["ExamType_" + CommonScore.GetAreaID + "_" + CommonScore.GetUserCode + "_" + CommonScore.GetSchoolMark].ToString());
            return Convert.ToInt32(temp);
        }
    }
    /// <summary>
    /// 取得考试id
    /// </summary>
    public static int ExamID
    {
        get
        {
            if (CommonScore.GetSchoolMark == "" || System.Web.HttpContext.Current.Session["ExamID_" + CommonScore.GetAreaID + "_" + CommonScore.GetUserCode + "_" + CommonScore.GetSchoolMark] == null)
            {
                return -1;
            }
            string temp = System.Web.HttpContext.Current.Server.UrlDecode(System.Web.HttpContext.Current.Session["ExamID_" + CommonScore.GetAreaID + "_" + CommonScore.GetUserCode + "_" + CommonScore.GetSchoolMark].ToString());
            return Convert.ToInt32(temp);
        }
    }

    /// <summary>
    /// 取得考试名
    /// </summary>
    public static string ExamName
    {
        get
        {
            if (CommonScore.GetSchoolMark == "" || System.Web.HttpContext.Current.Session["ExamName_" + CommonScore.GetAreaID + "_" + CommonScore.GetUserCode + "_" + CommonScore.GetSchoolMark] == null)
            {
                return "";
            }
            string temp = System.Web.HttpContext.Current.Server.UrlDecode(System.Web.HttpContext.Current.Session["ExamName_" + CommonScore.GetAreaID + "_" + CommonScore.GetUserCode + "_" + CommonScore.GetSchoolMark].ToString());
            return temp;
        }
    }

    /// <summary>
    /// 考试的年级
    /// </summary>
    public static int ExamGrade
    {
        get
        {
            if (CommonScore.GetSchoolMark == "" || System.Web.HttpContext.Current.Session["ExamGrade_" + CommonScore.GetAreaID + "_" + CommonScore.GetUserCode + "_" + CommonScore.GetSchoolMark] == null)
            {
                return -1;
            }
            string temp = System.Web.HttpContext.Current.Server.UrlDecode(System.Web.HttpContext.Current.Session["ExamGrade_" + CommonScore.GetAreaID + "_" + CommonScore.GetUserCode + "_" + CommonScore.GetSchoolMark].ToString());
            return Convert.ToInt32(temp);
        }
    }
    /// <summary>
    /// 考试的文理分科
    /// </summary>
    public static int ExamClassType
    {
        get
        {
            if (CommonScore.GetSchoolMark == "" || System.Web.HttpContext.Current.Session["ExamClassType_" + CommonScore.GetAreaID + "_" + CommonScore.GetUserCode + "_" + CommonScore.GetSchoolMark] == null)
            {
                return -1;
            }
            string temp = System.Web.HttpContext.Current.Server.UrlDecode(System.Web.HttpContext.Current.Session["ExamClassType_" + CommonScore.GetAreaID + "_" + CommonScore.GetUserCode + "_" + CommonScore.GetSchoolMark].ToString());
            return Convert.ToInt32(temp);
        }
    }

    /// <summary>
    /// 考试的文理分科
    /// </summary>
    public static int CanUploadScore
    {
        get
        {
            if (CommonScore.GetSchoolMark == "" || System.Web.HttpContext.Current.Session["CanUploadScore_" + CommonScore.GetAreaID + "_" + CommonScore.GetUserCode + "_" + CommonScore.GetSchoolMark] == null)
            {
                return -1;
            }
            string temp = System.Web.HttpContext.Current.Server.UrlDecode(System.Web.HttpContext.Current.Session["CanUploadScore_" + CommonScore.GetAreaID + "_" + CommonScore.GetUserCode + "_" + CommonScore.GetSchoolMark].ToString());
            return Convert.ToInt32(temp);
        }
    }

    ///// <summary>
    ///// 考试的副标题
    ///// </summary>
    ///// <param name="grade"></param>
    ///// <param name="classtype"></param>
    ///// <param name="examName"></param>
    ///// <returns></returns>
    //public static string CovertExamTitleEx(string examName)
    //{
    //    string examname = ""; ;
    //    string classtype = "";
    //    string examgrade = "";
    //    if (System.Web.HttpContext.Current.Request.Cookies.Get("examName") != null)
    //    {
    //        examname = System.Web.HttpContext.Current.Request.Cookies.Get("examName").Value;
    //    }
    //    if (System.Web.HttpContext.Current.Request.Cookies.Get("classType") != null)
    //    {
    //        classtype = System.Web.HttpContext.Current.Request.Cookies.Get("classType").Value;
    //    }
    //    if (System.Web.HttpContext.Current.Request.Cookies.Get("grade") != null)
    //    {
    //        examgrade = System.Web.HttpContext.Current.Request.Cookies.Get("grade").Value;
    //    }

    //    string str = "";
    //    if (classtype != "0")
    //    {
    //        str = string.Format("年级:{0} 文理科:{1} 报表类别:{2}", CommonScore.ConvertGradeNum(Convert.ToInt32(examgrade)), CommonScore.ConvertClassType(Convert.ToInt32(classtype)), examName);
    //    }
    //    else
    //    {
    //        str = string.Format("年级:{0} 报表类别:{1}", CommonScore.ConvertGradeNum(Convert.ToInt32(examgrade)), examName);
    //    }
    //    return str;
    //}

}
